﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace DBS
{
	public class BaseDALC : IDisposable
	{
		OleDbConnection _conn;
		public BaseDALC()
		{
			string constr = @"Provider=MSDAORA;Data Source=DBS_MON;Persist Security Info=True;User ID=DBS$MON;Password=DBS$MON";
			_conn = new OleDbConnection(constr);
		}

		public DataTable Fill(OleDbCommand selectCommand)
		{
			DataTable result = new DataTable();
			selectCommand.Connection = _conn;
			using (OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand))
				adapter.Fill(result);
			return result;
		}
		public DataTable Fill(string selectCommand)
		{
			using (OleDbCommand cmd = new OleDbCommand(selectCommand))
				return Fill(cmd);
		}

		void IDisposable.Dispose()
		{
			if (_conn != null)
			{
				_conn.Dispose();
				_conn = null;
			}
		}
	}
}
